﻿<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <base href="/" />
    <link rel="stylesheet" href="bootstrap/bootstrap.min.css" />
    <link rel="stylesheet" href="app.css" />
    <link rel="stylesheet" href="BlazorAppAuth.styles.css" />
    <link rel="stylesheet" href="css/all.min.css" />
    <link rel="icon" type="image/png" href="favicon.png" />
    <HeadOutlet />
</head>

<body>
    <Routes />
    <script src="_framework/blazor.web.js"></script>
    <script src="js/jquery.min.js"></script>
    <script src="js/jquery-ui.min.js"></script>
    <script src="bootstrap/bootstrap.bundle.min.js"></script>
    <script src="captcha.js"></script>
    <script>
        window.closeDialog = function (modalId) {
            var modalElement = document.getElementById(modalId);
            if (modalElement) {
                var bootstrapModal = bootstrap.Modal.getInstance(modalElement);
                if (bootstrapModal) {
                    bootstrapModal.hide();
                } else {
                    console.warn('Bootstrap Modal instance not found for element with id:', modalId);
                }
            } else {
                console.warn('Modal element not found with id:', modalId);
            }
        };

        // 下载excel
        function downloadFile(fileName, base64) {
            var link = document.createElement('a');
            link.download = fileName;
            link.href = 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,' + base64;
            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link);
        }

        window._captcha = null;

        // 验证码
        function generate_captcha() {
            new Captcha().draw(document.querySelector("#captcha_el"), r => { window._captcha = r; })
        }

        // the html code is in Dialogs.razor
        window.info_dialog = new bootstrap.Modal('#InfoModal');

        function toggle_dialog(message) {
            document.getElementById('infoMessage').innerText = message;
            info_dialog.toggle();
        }

        // 确保可以显示验证码
        window.document.addEventListener('DOMContentLoaded', function () {
            generate_captcha()
        });
    </script>
</body>

</html>
